using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;
using InfoSoftGlobal;


/// <summary>
/// Summary description for generateChart
/// </summary>
public class generateChart
{
    SQLInteract objSQL = new SQLInteract();
	public generateChart()
	{
		//
		// TODO: Add constructor logic here
		//
	}
 
    public string GenerateBarChartXML(string project_list, Array statusClosedarray, Array statusOpenarray, Array statusNewarray, Array statusFixedarray, Array statusReopenarray, string release_name)
    {
        string strXML = "";
        strXML = "<graph xaxisname='Projects' yaxisname='Number of Defects' hovercapbg='DEDEBE' hovercapborder='889E6D' rotateNames='1' yAxisMaxValue='100' numdivlines='9' divLineColor='CCCCCC' divLineAlpha='80' decimalPrecision='0' showAlternateHGridColor='1' AlternateHGridAlpha='30' AlternateHGridColor='CCCCCC' caption='Bar Chart - " + release_name + "' subcaption=''>";

        //CATEGORIES
        strXML += "<categories font='Arial' fontSize='11' fontColor='000000'>";
        string project_list_new = project_list.Replace("'", " ");
        foreach (string items in project_list.ToString().Split(new char[] { ',' }))
        {
            string itm = "";
            if (items.ToString().IndexOf('(') != -1)
            {
                string tmpitm = items.ToString().Remove(items.ToString().IndexOf('('), ((items.Length - 1) - items.ToString().IndexOf('(')));
                if (tmpitm.Length > 30)
                {
                    itm = tmpitm.Substring(0, 30) + "..'";
                }
                else
                {
                    itm = tmpitm;
                }
            }
            else
            {
                itm = items.ToString().Trim();
            }
            strXML += "<category name=" + itm.ToString().Trim() + " />";
        }
        strXML += "</categories>";

        //statusClosed
        strXML += "<dataset seriesname='Closed' color='8BBA00'>";
        foreach (string items in statusClosedarray)
        {
            if (items != "")
            {
                strXML += "<set value='" + items + "' />";
            }
        }
        strXML += "</dataset>";

        //statusOpen
        strXML += "<dataset seriesname='Open' color='F6BD0F'>";
        foreach (string item in statusOpenarray)
        {
            if (item != "")
            {
                strXML += "<set value='" + item + "' />";
            }
        }
        strXML += "</dataset>";

        //statusNew
        strXML += "<dataset seriesname='New' color='008ED6'>";
        foreach (string item in statusNewarray)
        {
            if (item != "")
            {
                strXML += "<set value='" + item + "' />";
            }
        }
        strXML += "</dataset>";

        //StatusFixed
        strXML += "<dataset seriesname='Fixed' color='8E468E'>";
        foreach (string item in statusFixedarray)
        {
            if (item != "")
            {
                strXML += "<set value='" + item + "' />";
            }
        }
        strXML += "</dataset>";

        //StatusReopen
        strXML += "<dataset seriesname='Reopen' color='9D080D'>";
        foreach (string item in statusReopenarray)
        {
            if (item != "")
            {
                strXML += "<set value='" + item + "' />";
            }
        }
        strXML += "</dataset>";
        strXML += "</graph>";
        return strXML;
    }

    public string TrendChartXMLTestPhase(ArrayList date_list, Array statusClosedarray, Array statusReopenarray, string release_name)
    {
        string strXML = "";

        strXML = "<graph caption='Defect Status' subcaption='' hovercapbg='FFECAA' hovercapborder='F47E00' formatNumberScale='0' decimalPrecision='0' showvalues='0' numdivlines='10' numVdivlines='0' yaxisminvalue='100' yaxismaxvalue='100' rotateNames='1'>";

        //CATEGORIES
        strXML += "<categories>";
        foreach (string items in date_list)
        {
            if (items.ToString() != "")
            {
                strXML += "<category name='" + items.ToString().Trim() + "' />";
            }
        }
        strXML += "</categories>";

        //statusClosed
        strXML += "<dataset seriesName='Closed' color='F1683C' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>";
        foreach (string items in statusClosedarray)
        {
            if (items != "")
            {
                strXML += "<set value='" + items + "' />";
            }
        }
        strXML += "</dataset>";

        //StatusReopen
        strXML += "<dataset seriesName='Open' color='2AD62A' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>";
        foreach (string item in statusReopenarray)
        {
            if (item != "")
            {
                strXML += "<set value='" + item + "' />";
            }
        }
        strXML += "</dataset>";
        strXML += "</graph>";
        return strXML;
    }

    public string TrendChartXMLForDefectReason(ArrayList date_list, Array statusClosedarray, Array statusReopenarray, string release_name)
    {
        string strXML = "";

        strXML = "<graph caption='Defect Status' subcaption='' hovercapbg='FFECAA' hovercapborder='F47E00' formatNumberScale='0' decimalPrecision='0' showvalues='0' numdivlines='10' numVdivlines='0' yaxisminvalue='100' yaxismaxvalue='100' rotateNames='1'>";

        //CATEGORIES
        strXML += "<categories>";
        foreach (string items in date_list)
        {
            if (items.ToString() != "")
            {
                strXML += "<category name='" + items.ToString().Trim() + "' />";
            }
        }
        strXML += "</categories>";

        //statusClosed
        strXML += "<dataset seriesName='Invalid' color='F1683C' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>";
        foreach (string items in statusClosedarray)
        {
            if (items != "")
            {
                strXML += "<set value='" + items + "' />";
            }
        }
        strXML += "</dataset>";

        //StatusReopen
        strXML += "<dataset seriesName='Valid' color='2AD62A' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>";
        foreach (string item in statusReopenarray)
        {
            if (item != "")
            {
                strXML += "<set value='" + item + "' />";
            }
        }
        strXML += "</dataset>";
        strXML += "</graph>";
        return strXML;
    }
}
